<template>
  <div class="app-container">
    <router-view v-slot="{ Component }">
      <component 
        :is="Component" 
        :key="$route.fullPath" 
        v-if="Component"
      />
    </router-view>
  </div>
</template>

<script setup>
import { useRouter, useRoute } from 'vue-router'

import { ref, provide } from 'vue'

const locationInfo = ref('')
const actualLocationCity = ref('')

provide('locationInfo', locationInfo)
provide('actualLocationCity', actualLocationCity)
provide('updateLocation', (newLocation) => {
  locationInfo.value = newLocation
  localStorage.setItem('lastLocation', newLocation)
  localStorage.setItem('locationTimestamp', Date.now().toString())
})
provide('updateActualLocation', (city) => {
  actualLocationCity.value = city
  localStorage.setItem('actualLocationCity', city)
})

const router = useRouter()

const logout = () => {
  localStorage.removeItem('token')
  localStorage.removeItem('user')
  router.push('/login')
}
</script>

<style>
.app-container {
  min-height: 100vh;
  width: 100%;
}

/* 移除所有过渡动画，直接渲染组件 */
</style>
